class code3 {
    //搜索插入位置
    public int searchInsert(int[] nums, int target) {
        int l = 0;
        int r = nums.length-1;
        //特判：边界情况
        if(nums[r]<target) return r+1;
        while(l < r) {
            int mid = l + (r-l)/2;
            if(nums[mid] < target) {
                l = mid+1;
            } else {
                r = mid;
            }
        }
        return r;
    }
}